var CryptoJS = require("crypto-js");
module.exports = {
    aes: aes,
    deaes: deaes
};
function aes(data, key, iv, type = 'aes-256-cbc') {
    key = CryptoJS.enc.Utf8.parse(key);
    iv = CryptoJS.enc.Utf8.parse(iv);
    var ciphertext = CryptoJS.AES.encrypt(data, key, {
        iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return ciphertext.toString();
}
function deaes(data, key, iv, type = 'aes-256-cbc') {
    key = CryptoJS.enc.Utf8.parse(key);
    iv = CryptoJS.enc.Utf8.parse(iv);
    var bytes = CryptoJS.AES.decrypt(data, key, {
        iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    var originalText = bytes.toString(CryptoJS.enc.Utf8);
    return originalText;
}